{extend name="public/base" /}
{block name="style"}<link href="__LIB__/fileinput/css/fileinput.min.css" rel="stylesheet" /> {/block}
 {block name="body"}
  <div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li>
			<a href="{:url('index')}">规格列表</a>
		</li>
		<li><strong>商品规格管理</strong></li>
	</ol>
</div>
<button  class="form-control my_but">删除</button>
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<div class="ibox-content">
				<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('edit')}">
					<input type="hidden" name="id" value="{$ad.id}" />
					<div class="form-group">
						<label class="col-sm-3 control-label">规格名称：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="name" name="name" value="{$ad.name}" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">规格属性值：</label>
						<div id="spec_value" class="input-group col-sm-4">
							{volist name="specValues" id="vo"}
								<input style="width: 20%;margin-top: 10px;border-radius: 5px 5px 5px 5px;" type="text" id="my_spec" value="{$vo.value}"  class="form-control" />
								<button type="button" onclick="btn_onclick({$vo.id})" style="padding: 0;width: 10%;margin-right: 10px;margin-top: 10px;border-radius: 5px 5px 5px 5px;background-color: #1ab394;color: #fff;"  class="form-control">删除</button>
							{/volist}
						</div>
						<button style="margin-top: 10px;margin-left: 35%;" onclick="myFunction()" class="btn btn-primary" type="button"> 增 加 属 性 </button>&nbsp;&nbsp;
					</div>
					
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">排序：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="displayorder" name="displayorder" value="{$ad.displayorder}" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3">
							<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;
							<a href="{:url('index')}" class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script>
	upload_one('__IMG__/default.jpg');
	$(function() {
		$("#myForm").validate({
			rules: {
				name: "required"
			},
			messages: {
				name: ICON.error + "请输入规格",
			},
			submitHandler: function(form) {
				ajaxForm();
			}
		});
	});
</script>
<script>
	function myFunction()
	{
		var put="<input name='value[]' style='width: 25%;margin-top: 10px;border-radius: 5px 5px 5px 5px;' type='text'  class='form-control' />";
		/*var but ="<button type='button' onclick='btn_onclick({$vo.id})' style='padding: 0;width: 10%;margin-right: 10px;margin-top: 10px;border-radius: 5px 5px 5px 5px;background-color: #1ab394;color: #fff;'  class='form-control'>删除</button>"*/
		//document.getElementById("spec_value").innerHTML(cln);
		$("#spec_value").append(put);
	}
</script>
<script>
	function btn_onclick(id){
		  		$.ajax({
                    type:"POST",
                    url:"/web/spec/delete_specval?id="+id,
                    dataType:"json",
                    timeout:30000,
                    error:function(){
                        alert("删除失败！");
                    },
                    success:function(data){
                    		alert("删除成功！");
                    		 location.reload();
                    }
                });
	}
</script>
{/block}